
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style type="text/css">
 
  </style>
</head>
<body>
  <div id="app">
    <div>{{reverseString}}</div>
    <div>{{reverseString}}</div>
    <div>{{reverseMessage()}}</div>
    <div>{{reverseMessage()}}</div>

  </div>

  <script type="text/javascript" src="./js/vue.js"></script>
  <script type="text/javascript">
    /*
      计算属性
    */
    var vm = new Vue({
      el: '#app',
      data: {
       msg:"lvchengxin" ,
       num: 100

      },
      methods: {
        reverseMessage() {
           console.log('methods');
          return this.msg.split('').reverse().join('');
        }
      },
      computed: {
        reverseString() {
          console.log('computed');
          // return this.msg.split('').reverse().join('');
          var total = 0
          for(var i = 0; i <= this.num; i++) {
            total += i;
          }
          return total;
        }
      }
    });
  </script>
</body>
</html>
